package de.karlNet.sambamanager.ldapController.commands;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ldap.core.LdapTemplate;

import de.karlNet.sambamanager.ldapController.LdapMemberOfTree;
import de.karlNet.sambamanager.ldapController.LdapMemberTree;
import de.karlNet.sambamanager.ldapController.OriginalLdapTree;

public abstract class BaseCommand {
	@Value("${ldap.baseDN}")
	protected String baseDN;
	@Autowired
	private List<OriginalLdapTree> originalLdapTree;
	@Autowired
	protected LdapMemberTree ldapMemberTree;
	@Autowired
	protected LdapMemberOfTree ldapMemberOfTree;
	@Autowired
	@Qualifier("ldapTemplate")
	protected LdapTemplate ldapTemplate;

	public void resetTrees() {
		for (OriginalLdapTree originalLdapTree : this.originalLdapTree) {
			try {
			originalLdapTree.reset();
			} catch(Exception e) {
				e.printStackTrace();
			}
		}

		this.ldapMemberTree.reset();
		this.ldapMemberOfTree.reset();
	}

	protected BaseCommand() {
		// TODO Auto-generated constructor stub
	}

}
